package com.mc.music_web.controller;

import com.mc.music_web.entity.MV;
import com.mc.music_web.services.MvVoService;
import com.mc.music_web.vo.MVvo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class MVController {

    @Autowired
    private MvVoService mvVoService;


    @RequestMapping("/admin/lastMV")
    public  String goMV(){

        return "/admin/mv";
    }

    @RequestMapping("/admin/mvList")
    @ResponseBody
    public List mvList(){
        List<MVvo> list=mvVoService.selectMVvo();
        return list;
    }

    @RequestMapping("/admin/mvDel")
    @ResponseBody
    public int delMV(Integer mvId) {
        int result = mvVoService.delteMVvo(mvId);
        return result;
    }


    @RequestMapping("/admin/goMVUpdate")
    @ResponseBody
    public MV updateMV(Integer mvId) {

        MV mv = mvVoService.selectByMv(mvId);

        return mv;
    }


    @RequestMapping("/admin/doMVUpdate")
    @ResponseBody
    public MV doUpdateSong(MV mv) {

        mvVoService.updateMVvo(mv);
        return mv;
    }


 /*   @RequestMapping("/admin/goSongLimit")
    @ResponseBody
    public PageInfo selectSongLimit(int pageNum, HttpSession session) {
        PageInfo<Song> pageInfosO = songVoService.selectSongLimit(pageNum);
        session.setAttribute("songSession",pageInfosO);
        return pageInfosO;
    }*/






    @RequestMapping("/admin/addMVs")
    @ResponseBody
    public Integer addMV(MV mv){

        Integer i = mvVoService.insertMVvo(mv);
        return i;
    }

    @RequestMapping("/admin/adminByMv")
    @ResponseBody
    public  List  selectByMVvo(String keyword){
        List<MVvo> list=mvVoService.selectByMVvo(keyword);
        return list;
    }
}
